package com.hope.saas.guice;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.hope.saas.guice.service.AccountService;
import com.hope.saas.guice.service.AccountServiceImpl;
import com.hope.saas.guice.service.CarService;
import com.hope.saas.guice.service.CarServiceImpl;

/**
 * 接口与实例绑定，创建实例。将实例纳入到 Guice 容器管理
 */
public class GuiceConfig extends AbstractModule {
    @Override
    protected void configure() {
        bind(AccountService.class).to(AccountServiceImpl.class).in(Scopes.SINGLETON);
    }

    /**
     * 类似 Spring 的 @Bean
     */
    @Provides
    public CarService getCarService() {
        return new CarServiceImpl();
    }
}